﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Diagnostics;
using System.Xml.Linq;
using System.IO;
using System.Deployment.Application;

namespace ParsecClient
{
    /// <summary>
    /// Interaction logic for ShareFightSuccess.xaml
    /// </summary>
    public partial class ShareFightSuccess : Window
    {
        public ShareFightSuccess()
        {
            InitializeComponent();
        }
        public int LinkFightId = 0;
        private void lnkVisit_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
        {
            try
            {
            Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
            e.Handled = true;
            }
            catch (Exception ex)
            {
                ((App)Application.Current).HandleError("Error Opening Link", "Error on lnkVisit_RequestNavigate", ex, this, true);
            }
        }

        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Close();
            }

        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
            string uri =string.Format(App.ParsecShareUrl, LinkFightId);
            lnkVisit.NavigateUri = new Uri(uri);
            lnkVisit.Inlines.Clear();
            lnkVisit.Inlines.Add(uri);
            }
            catch (Exception ex)
            {
                ((App)Application.Current).HandleError("Error Loading Share Success Window", "Error on ShareFightSuccess.Window_Loaded", ex, this, true);
            }
        }

        private void btnCopy_Click(object sender, RoutedEventArgs e)
        {
            try
            {
            Clipboard.SetText(lnkVisit.NavigateUri.ToString());
            }
            catch (Exception ex)
            {
                ((App)Application.Current).HandleError("Error Copying to Clipboard", "Error on btnCopy_Click", ex, this, true);
            }
        }
    }
}
